4 extension CVImageBuffer {
6 static let sharedContext = CIContext()
8 var cgImage: CGImage? {
9 let ciImage = CIImage(cvImageBuffer: self)
10 return CVImageBuffer.sharedContext.createCGImage(ciImage, from: CGRect(x: 0, y: 0, width: CVPixelBufferGetWidth(self), height: CVPixelBufferGetHeight(self)))